home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / layout / nsIStyleRule.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  4KB  |  108 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37. #ifndef nsIStyleRule_h___
  38. #define nsIStyleRule_h___
  39.  
  40. #include <stdio.h>
  41.  
  42. #include "nsISupports.h"
  43.  
  44. class nsIStyleSheet;
  45. class nsPresContext;
  46. class nsIContent;
  47. struct nsRuleData;
  48.  
  49. // IID for the nsIStyleRule interface {40ae5c90-ad6a-11d1-8031-006008159b5a}
  50. #define NS_ISTYLE_RULE_IID     \
  51. {0x40ae5c90, 0xad6a, 0x11d1, {0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
  52.  
  53. /**
  54.  * An object implementing |nsIStyleRule| (henceforth, a rule) represents
  55.  * immutable stylistic information that either applies or does not apply
  56.  * to a given element.  It belongs to an object or group of objects that
  57.  * implement |nsIStyleSheet| and |nsIStyleRuleProcessor| (henceforth, a
  58.  * sheet).
  59.  *
  60.  * A rule becomes relevant to the computation of style data when
  61.  * |nsIStyleRuleProcessor::RulesMatching| creates a rule node that
  62.  * points to the rule.  (A rule node, |nsRuleNode|, is a node in the
  63.  * rule tree, which is a lexicographic tree indexed by rules.  The path
  64.  * from the root of the rule tree to the |nsRuleNode| for a given
  65.  * |nsStyleContext| contains exactly the rules that match the element
  66.  * that the style context is for, in priority (weight, origin,
  67.  * specificity) order.)
  68.  *
  69.  * The computation of style data uses the rule tree, which calls
  70.  * |nsIStyleRule::MapRuleInfoInto| below.
  71.  *
  72.  * It is worth emphasizing that the data represented by a rule
  73.  * implementation are immutable.  When the data need to be changed, a
  74.  * new rule object must be created.  Failing to do this will lead to
  75.  * bugs in the handling of dynamic style changes, since the rule tree
  76.  * caches the results of |MapRuleInfoInto|.
  77.  *
  78.  * |nsIStyleRule| objects are owned by |nsRuleNode| objects (in addition
  79.  * to typically being owned by their sheet), which are in turn garbage
  80.  * collected (with the garbage collection roots being style contexts).
  81.  */
  82.  
  83.  
  84. class nsIStyleRule : public nsISupports {
  85. public:
  86.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_IID)
  87.  
  88.   /**
  89.    * |nsIStyleRule::MapRuleInfoInto| is a request to copy all stylistic
  90.    * data represented by the rule that:
  91.    *   + are relevant for |aRuleData->mSID| (the style struct ID)
  92.    *   + are not already filled into the data struct
  93.    * into the appropriate data struct in |aRuleData|.  It is important
  94.    * that only empty data are filled in, since the rule tree is walked
  95.    * from highest priority rule to least, so that the walk can stop if
  96.    * all needed data are found.  Thus overwriting non-empty data will
  97.    * break CSS cascading rules.
  98.    */
  99.   NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData)=0;
  100.  
  101. #ifdef DEBUG
  102.   NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0;
  103. #endif
  104. };
  105.  
  106.  
  107. #endif /* nsIStyleRule_h___ */
  108.